/* libwatopt++ - Optimization Toolkit
 *
 * Copyright (c) 2007 Christopher Alexander Watford
 * <christopher.watford@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 *
 * $Id: hopfield_network.hpp 2 2007-05-06 18:01:15Z christopher.watford $
 */

#if _MSC_VER > 1000
#pragma once
#endif /* _MSC_VER > 1000 */

#ifndef _HOPFIELD_HPP_
#define _HOPFIELD_HPP_

namespace watopt
{

   class HopfieldNetwork
   {
   public:
	   HopfieldNetwork(
		   size_t nodes,
		   double tau=2.0,
		   double dt=0.8,
		   double alpha=1.0,
		   double eps=0.0001
	   );

	   ~HopfieldNetwork(void);

	   double alpha(void) const { return _alpha; }
	   double tau(void) const { return _tau; }
	   double dt(void) const { return _dt; }
	   double epsilon(void) const { return _eps; }

	   double* Get_u(void) const;
	   double* Get_I(void) const;
	   double* Get_V(void) const;
   #define Get_T_Index(i,j,n) ((i * n) + j)
	   double* Get_T(void) const;

	   double* CreateInputArray(void) const;

	   double* Run(double* II, size_t input_count, size_t max_iterations);

   private:
	   size_t _nodes;
	   double *_TT;
	   double *_VV;
	   double *_uu;
	   double *_du;
	   double _tau;
	   double _dt;
	   double _alpha;
	   double _eps;
   };

   HopfieldNetwork* SetupKofN(size_t k, size_t n, double** inputs);

}

#endif /* !defined(_HOPFIELD_HPP_) */